package com.qidian.kk;

import java.util.function.IntBinaryOperator;

public class LambdaDemo02 {
    public static void main(String[] args) {
        int i = calculateNum((new IntBinaryOperator() {
            @Override
            public int applyAsInt(int left, int right) {
                return left + right;
            }
        }));
        System.out.println(i);

        // 使用lambda表达式
        int b = calculateNum((int left, int right) -> {
            return left + right;
        });
        System.out.println(b);
    }

    public static int calculateNum(IntBinaryOperator operator) {
        int a = 10;
        int b = 20;
        return operator.applyAsInt(a, b);
    }
}
